<?php

namespace service\client;

abstract class ServiceClient
{
    public function __call(string $method, array $arguments)
    {

        $className = $this->getClassName();
        $request = [
            'class'   => $className,
            'method'  => $method,
            'args'    => $arguments,
        ];

        $client = TcpClient::getInstance();
        $rs = $client->send($request);

        return $rs;
    }

    private function getClassName(){
        $className = get_class($this);
        $arr = explode("\\", $className);
        $name = end($arr);

        //去掉后缀

        $name = str_replace(['Srv', 'Service'], '', $name);

        return $name;
    }
}